package com.luckyframe.project.jmeter.consumer.watch;

import cn.hutool.core.thread.ThreadUtil;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;


@Component
public class WatchTaskManager implements InitializingBean {

    private ThreadPoolExecutor threadPoolExecutor=  new ThreadPoolExecutor(10, 100,
            0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>(),ThreadUtil.newNamedThreadFactory("jmeterWatcher",false));


    @Override
    public void afterPropertiesSet() throws Exception {


    }

    public void startPlanTask(PlanWatchTask planWatchTask){
        threadPoolExecutor.submit(planWatchTask);
    }

    public void startCaseTask(CaseWatchTask caseWatchTask){
        threadPoolExecutor.submit(caseWatchTask);
    }



}
